package com.st.dao.impl;

import com.st.dao.IUserDao;
import com.st.entity.User;
import com.st.util.DBUtil;

public class UserDaoImpl implements IUserDao{

	private DBUtil dbUtil = new DBUtil();
	
	@Override
	public User select(User user) {
		String sql = "select * from user where username=? and password=?";
		Object[] params = {user.getUsername(), user.getPassword()};
		return dbUtil.queryOne(sql, params, User.class);
	}

	@Override
	public int update(Integer id, String newpassword) {
		String sql = "update user set password=? where id=?";
		Object[] params = {newpassword, id};
		return dbUtil.update(sql, params);
	}

	@Override
	public int updatePhoto(Integer id, String photo) {
		String sql = "update user set photo=? where id=?";
		Object[] params = {photo, id};
		return dbUtil.update(sql, params);
	}

}
